package main;

import java.util.ArrayList;
import util.FetchUtil;
import crawler.Extractor;
import crawler.CrawlerDocument;


public class HtmlRunner {

	public static void main(String[] args) {
		
		
		try{
			CrawlerDocument doc = new CrawlerDocument("http://www.lashou.com");
			
			FetchUtil.fetch(doc);
			
			Extractor ext = new Extractor();
			
			ext.Extract(doc);
			
			ArrayList<CrawlerDocument> outlinks = doc.getOutlinks();
			
			System.out.println("size = " + outlinks.size());
			
			for(int i = 0; i < outlinks.size(); ++i){
				CrawlerDocument extDoc = outlinks.get(i);				
				System.out.println("link = "+ extDoc.getFeature("link"));
				System.out.println("image = " + extDoc.getFeature("image"));
				System.out.println("text = " + extDoc.getFeature("text"));
				System.out.println("price = " + extDoc.getFeature("price"));
				System.out.println("----------------------------------------");				
			}

		}catch(Exception e){
			e.printStackTrace();
		}
		
	}

}
